$SAVE
$NOLIST
;************************************************************************
;*									*
;*    R T X - 51  :  MACRO: GET READY PRIORITY                          *
;*							     		*
;*----------------------------------------------------------------------*
;*                                                                      *
;*    Filename     :   RTXGETPR.INC                                     *
;*    Language     :   Keil A-51                                        *
;*    Dev. system  :   Keil uVision2                                    *
;*    Targetsystem :   Any system based upon 8051 up                    *
;*                                                                      *
;*    Purpose      :   Get highest ready task priority.                 *
;*                     To be used as an include file                    *
;*								     	*
;*----------------------------------------------------------------------*
;* Rev. |  Released   | Programmer    | Comments                        *
;*----------------------------------------------------------------------*
;* 0.1  |  4.1.1991   | E. Glatz      | For V3.20                       *
;* 0.2  |  7.3.1991   | Th. Fischler  | Adapted to Keil C-51            *
;* 0.3  | 15.7.1991   | Th. Fischler  | Returns FFH when no tasks in    *
;*      |             |               | list                            *
;* 7.00 |  13.11.2001 | T. Mueller    | Release 7.00                    *
;************************************************************************
;*    Copyright 1991 .. 2001 METTLER  &  FUCHS  AG,  CH-8953 Dietikon   *
;************************************************************************

GET_RDY_PRIO   MACRO
               LOCAL PRIO0, PRIO1, PRIO2, PRIO3
;;
;;      RETURNS THE HIGHEST READY PRIO. IN ACC
;;
;;
;;      SIDE EFFECTS: uses ACC
;;
               CLR     A
               CJNE    A,?RTX_RDY_COUNT3,PRIO3     ; Jump if prio.=3
               CJNE    A,?RTX_RDY_COUNT2,PRIO2     ; Jump if prio.=2
               CJNE    A,?RTX_RDY_COUNT1,PRIO1     ; Jump if prio.=1
               CJNE    A,?RTX_RDY_COUNT0,PRIO0     ; Jump if prio.=0
               MOV     A, #0FFH-3
PRIO3:         INC     A
PRIO2:         INC     A
PRIO1:         INC     A
PRIO0:
               ENDM
$RESTORE
